package logic_setting_api

import (
	v1 "Sailor/app/Sailor-console-server/api/api_setting_api/v1"
	"Sailor/app/Sailor-console-server/internal/dao"
	"Sailor/app/Sailor-console-server/internal/model/entity"
	"context"
	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
)

func (s *sSettingApi) LogicSettingApiList(ctx context.Context, req *v1.SettingApiListReq) (res *v1.SettingApiListRes, err error) {

	var apis []entity.SysApi
	var total int
	err = dao.SysApi.Ctx(ctx).Page(req.Page, req.PageSize).ScanAndCount(&apis, &total, true)
	if err != nil {
		g.Log().Error(ctx, err)
		return nil, gerror.New("查询失败")
	}
	return &v1.SettingApiListRes{
		Page:     req.Page,
		PageSize: req.PageSize,
		Rows:     apis,
		Total:    total,
	}, nil
}
